package Eyjafjalla.helper;

import Eyjafjalla.effect.CampfireMarkEffect;
import com.badlogic.gdx.Gdx;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.UIStrings;
import com.megacrit.cardcrawl.ui.campfire.AbstractCampfireOption;

public class FireMarkOption extends AbstractCampfireOption {
    private static final UIStrings uiStrings;

    public FireMarkOption(boolean active){
        FireTimes = 0;
        this.label = uiStrings.TEXT[1];
        this.usable = active;
        this.img = ImageMaster.loadImage("EyjafjallaResources/img/events/fireButton.png");
        updateUsability(active);
    }

    public static int FireTimes;

    float timer = 0.1f;

    public void updateUsability(boolean canUse){
        this.description = canUse?uiStrings.TEXT[2]:uiStrings.TEXT[3];
    }

    @Override
    public void useOption() {
        if(this.usable){
            AbstractDungeon.effectList.add(new CampfireMarkEffect());
        }
    }

    @Override
    public void update() {
        super.update();
        timer-= Gdx.graphics.getDeltaTime();
        if(timer<0){
            timer = 0.1f;
            this.usable = EyjafjallaHelper.hasFireableCards();
            updateUsability(this.usable);
        }
    }

    static {
        uiStrings = CardCrawlGame.languagePack.getUIString(StringHelper.CAMPFIRE_OPERATION);
    }
}

